async function ajax(json) {
	json.method=json.method.toUpperCase()||'GET';
	json.url=json.url.endsWith('/')?json.url.substr(0, json.url.length-1): json.url;
	
	let data=[];
	let body=json.body;
	for(let key in body) {
		data.push(`${key}=${body[key]}`)
	}
	console.log(data);
	return new Promise((resolve, reject)=>{
		let xhr=new XMLHttpRequest();
		if(json.method==='GET') {
			xhr.open(json.method, `${json.url}/?${data.join('&')}`);
			xhr.send();
		} else {
			xhr.open(json.method, json.url);
			xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			xhr.send(data.join('&'));
		}
		xhr.onreadystatechange=function() {
			if(xhr.readyState===4) {
				let status=xhr.status;
				if(status>=200 && status<300 || xhr.status===304) {
					resolve(xhr.responseText);
				} else {
					reject('通信失败');
				}
			}
		}
	})
}